/// <reference path="../_all.ts" />

module Application.Resources {
    export interface IServerClass extends ng.resource.IResourceClass {
    }

    export interface IServer extends ng.resource.IResource {
        server_id: number;
        group_id: number;
        name: string;
        server_port: number;
        path: string;
        executable: string;
        config_path: string;
        template_path: string;
        role: number;
        is_started: boolean;
        is_starting: boolean;
        is_stopped: boolean;
        is_stopping: boolean;
        is_updating: boolean;
        last_datetime: Date;
        created_at: Date;
        updated_at: Date;

        configs: Application.Resources.IConfig[];
        templates: Application.Resources.ITemplate[];
    }

    export class ServerUtility {
        static fixBooleans(item: IServer) {
            item.is_started = Application.Utility.Booleans.parse(item.is_started);
            item.is_starting = Application.Utility.Booleans.parse(item.is_starting);
            item.is_stopped = Application.Utility.Booleans.parse(item.is_stopped);
            item.is_stopping = Application.Utility.Booleans.parse(item.is_stopping);
            item.is_updating = Application.Utility.Booleans.parse(item.is_updating);
        }
    }
}